CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)

PROJECT(dgpp_rocksdb VERSION 0.1.0)

SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_STANDARD 17)
SET(ROCKSDB_DIR "${PROJECT_SOURCE_DIR}/rocksdb")

MESSAGE(STATUS "PROJECT_BINARY_DIR =  " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "PROJECT_SOURCE_DIR =  " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "CMAKE_SOURCE_DIR   =  " ${CMAKE_SOURCE_DIR})
MESSAGE(STATUS "ROCKSDB_DIR        =  " ${ROCKSDB_DIR})

INCLUDE_DIRECTORIES(${ROCKSDB_DIR}/include)
INCLUDE_DIRECTORIES( "/usr/local/include")

add_custom_target(BUILD_ROCKSDB
    COMMAND make -j2 shared_lib -C ${ROCKSDB_DIR}
    COMMENT "Building RocksDB"
)

ADD_EXECUTABLE(dgpp_rocksdb main.cpp)
ADD_DEPENDENCIES(dgpp_rocksdb BUILD_ROCKSDB)
ADD_EXECUTABLE(secondary ./test/secondary.cpp)
ADD_DEPENDENCIES(secondary BUILD_ROCKSDB)
FIND_LIBRARY(LIB_GFLAGS gflags)
FIND_LIBRARY(LIB_DL dl)
TARGET_LINK_LIBRARIES(dgpp_rocksdb PRIVATE ${ROCKSDB_DIR}/librocksdb.so ${LIB_DL} ${LIB_GFLAGS} pthread)
TARGET_LINK_LIBRARIES(secondary PRIVATE ${ROCKSDB_DIR}/librocksdb.so ${LIB_DL} ${LIB_GFLAGS} pthread)
